﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.AccessControl;
using System.Web;
using System.Web.Mvc;

namespace AngularJsWebApplication1.Controllers
{
    public class HomeController : Controller
    {
        // GET: Home
        public ActionResult Index()
        {
            return View();
        }   
public ActionResult Second()
        {
            return View();
        }
        [HttpPost]
        public ActionResult GetList(long? Id)
        {
            var list = new List<User>
            {
                new User
                {
                    Id = 10001,
                    Name = "张三1",
                    Age = (18 + new Random(Guid.NewGuid().GetHashCode()).Next(10))
                },
                new User
                {
                    Id = 10002,
                    Name = "张三2",
                    Age = (18 + new Random(Guid.NewGuid().GetHashCode()).Next(10))
                },
                new User
                {
                    Id = 10003,
                    Name = "张三3",
                    Age = (18 + new Random(Guid.NewGuid().GetHashCode()).Next(10))
                },
                new User
                {
                    Id = 10004,
                    Name = "张三4",
                    Age = (18 + new Random(Guid.NewGuid().GetHashCode()).Next(10))
                },
                new User
                {
                    Id = 10005,
                    Name = "张三5",
                    Age = (18 + new Random(Guid.NewGuid().GetHashCode()).Next(10))
                }
            };

            if (Id.HasValue)
            {
                list.Add(new User
                {
                    Id = Id.Value,
                    Name = "张三" + Id.Value,
                    Age = (18 + new Random(Guid.NewGuid().GetHashCode()).Next(10))
                });
            }

            return Json(list);
        }
    }

    public class User
    {
        public long Id { get; set; }
        public string Name { get; set; }
        public int Age { get; set; }
    }
}